<!--引入CSS-->
<link href="${rc.getContextPath()}/manage/js/businessJs/my_webuploader.css" rel="stylesheet" type="text/css" />
<style type="text/css">
    span.error {
        left: 148px;
        top : 2px
    }
</style>
<script type="text/javascript">
    $(function(){
        setTimeout(function(){
            $($jtabs[2]).hide();
            $($jgroups[2]).hide();
            $($jtabs[3]).hide();
            $($jgroups[3]).hide();
            $("div#uploadProcessInspectPicture").hide();

        }, 0);

        $("input[name='graphcollectFlag']").click(function(){
            if($(this).attr("checked")){
                $("div#uploadProcessInspectPicture").show();
            }else{
                alertMsg.confirm("<@label key='graphicsUploadFile.M'>附件上传只对图形采集有效！</@label>", {
                    okCall: function(){
                        $("div#uploadProcessInspectPicture").hide();
                    },
                    cancelCall: function(){
                        $("input[name='graphcollectFlag']").attr("checked",true);
                    }
                });
            }
        })
    });
    var $currentDialog = $.pdialog.getCurrent();

    var $jTabHeader = $("> .tabsHeader", $("div.tabs", $currentDialog));

    var $jtabs = $(">.tabsHeaderContent>ul li", $jTabHeader);

    var $jgroups = $("> .tabsContent > *", $("div.tabs", $currentDialog));

    var componentCount = 0;

    var processAttachmentCount = 0;

    var inspectPictureCount = 0;

    var capacityCount = 0;

    var processFile = [];

    function popDialogAjaxDone(json) {
        DWZ.ajaxDone(json);
        var standardCapacity = $("input[name='standardCapacity']",$.pdialog.getCurrent()).val();
        var standardHours = $("input[name='standardHours']",$.pdialog.getCurrent()).val();
        if(""!=standardCapacity && ""===standardHours){
            alertMsg.error("标准用时不能为空！");
            return false;
        }
        if(""==standardCapacity && ""!=standardHours){
            alertMsg.error("标准产能不能为空！");
            return false;
        }
        if (json.statusCode == DWZ.statusCode.ok) {
            processOperationJs._addProcessOperations(json.data, $currentDialog);
        }
    }

    function _updaeTabsConetent(_args){
        if(_args){
            var operationTypeEcode = _args["operationTypeEcode"];
            if(operationTypeEcode == "QUALITY"){
                _qualitytabsShow();
            }else{
                _productiontabsShow();
            }
        }
    }

    function _qualitytabsShow() {
        $($jtabs[0]).addClass("selected");
        $($jgroups[0]).show();
        $($jtabs[1]).show();
        $($jgroups[1]).hide();
        $($jtabs[2]).hide();
        $($jgroups[2]).hide();
        $($jtabs[3]).removeClass("selected");
        $($jtabs[3]).show();
        $($jgroups[3]).hide();
    }

    function _productiontabsShow() {
        $($jtabs[0]).addClass("selected");
        $($jgroups[0]).show();
        $($jtabs[1]).show();
        $($jgroups[1]).hide();
        $($jtabs[2]).show();
        $($jgroups[2]).hide();
        $($jtabs[3]).hide();
        $($jgroups[3]).hide();
    }

    function _addProcessAttachment(data) {
        if(!data)
            return;
        processAttachmentCount ++ ;
        var gridTheadTh = $("#processAttachMentTable", $currentDialog).find("table thead th");
        var _id = "processAttachment_"+processAttachmentCount;
        var tr = "<tr id="+_id+">";
        tr += "<td style='width:"+$(gridTheadTh[0]).width()+"px'><div>"+data.fileName+"</div><input type='hidden' name='attachment["+processAttachmentCount+"].fileName' value='"+data.fileName+"'/></td>";
        tr += "<td style='width:"+$(gridTheadTh[1]).width()+"px'><div>"+Math.round(data.fileSize/1024)+"kb</div><input type='hidden' name='attachment["+processAttachmentCount+"].attachmentCode' value='"+data.attachmentCode+"'/></td>";
        tr += "<td style='width:"+$(gridTheadTh[2]).width()+"px'><div><input type='text' class='textInput required' maxlength='20' name='attachment["+processAttachmentCount+"].version'/></div></td>";
        tr += "<td style='width:"+$(gridTheadTh[3]).width()+"px'><a title='<@label key='delete.B'>删除</@label>' target='ajax' class='btnDel' onclick='_delProcessAttachment(\""+_id+"\");'><@label key='delete.B'>删除</@label></a>";
        tr += "<a title='<@label key='download.B'>下载</@label>' target='dwzExport' class='btnAttach' href='${rc.getContextPath()}/manage/common/downloadAttachement?attachmentCode="+data.attachmentCode+"&fileName="+data.fileName+"'></a></td>"
        tr += "</tr>";
        $("#processAttachMentTable .gridTbody", $currentDialog).find("table tbody").append(tr);
    }

    function _addProcessComponent(data) {
        if(!data)
            return;
        var gridTheadTh = $("#processComponentTable", $currentDialog).find("table thead th");
        var tr = "<tr id="+data["componentCode"]+">";
        tr += "<td style='width:"+$(gridTheadTh[0]).width()+"px'><div>"+data["componentCode"]+"</div><input type='hidden' name='component["+componentCount+"].componentCode' value='"+data["componentCode"]+"'/></td>";
        tr += "<td style='width:"+$(gridTheadTh[1]).width()+"px'><div>"+data["componentText"]+"</div></td>";
        tr += "<td style='width:"+$(gridTheadTh[2]).width()+"px'><div>"+data["quantity"]+"</div><input type='hidden' name='component["+componentCount+"].quantity' value='"+data["quantity"]+"'/></td>";
        tr += "<td style='width:"+$(gridTheadTh[3]).width()+"px'><a title='<@label key='delete.B'>删除</@label>' target='ajax' class='btnDel' onclick='_delProcessComponent(\""+data.componentCode+"\");'><@label key='delete.B'>删除</@label></a></td>";
        tr += "</tr>";
        $("tr#"+data.componentCode,  $currentDialog).remove();
        $("#processComponentTable .gridTbody",  $currentDialog).find("table tbody").append(tr);
        componentCount ++;
    }

    function _addInspectPicture(data) {
        if(!data )
            return;
        inspectPictureCount++;
        var gridTheadTh = $("#processInspectPicTable", $currentDialog).find("table thead th");
        var _id = "inspectPicture_"+inspectPictureCount;

        var tr = "<tr id="+_id+">";
        tr += "<td style='width:"+$(gridTheadTh[0]).width()+"px'><div>"+data.fileName+"</div><input type='hidden' name='picture["+inspectPictureCount+"].fileName' value='"+data.fileName+"'/></td>";
        tr += "<td style='width:"+$(gridTheadTh[1]).width()+"px'><div>"+Math.round(data.fileSize/1024)+"kb</div><input type='hidden' name='picture["+inspectPictureCount+"].attachmentCode' value='"+data.attachmentCode+"'/></td>";
        tr += "<td style='width:"+$(gridTheadTh[2]).width()+"px'><a title='<@label key='delete.B'>删除</@label>' target='ajax' class='btnDel' onclick='_delProcessAttachment(\""+_id+"\");'><@label key='delete.B'>删除</@label></a>";
        tr += "<a title='<@label key='download.B'>下载</@label>' target='dwzExport' class='btnAttach' href='${rc.getContextPath()}/manage/common/downloadAttachement?attachmentCode="+data.attachmentCode+"&fileName="+data.fileName+"'></a></td>"
        tr += "</tr>";
        $("#processInspectPicTable .gridTbody", $currentDialog).find("table tbody").append(tr);

    }

    function _addProcessCapacity(data) {
        if(!data)
            return;
        var gridTheadTh = $("#processCapacityTable", $currentDialog).find("table thead th");
        var tr = "<tr id="+data["workUnitCode"]+">";
        tr += "<td style='width:"+$(gridTheadTh[0]).width()+"px'><div>"+data["workUnitCode"]+"</div><input type='hidden' name='capacity["+capacityCount+"].workUnitCode' value='"+data["workUnitCode"]+"'/></td>";
        tr += "<td style='width:"+$(gridTheadTh[1]).width()+"px'><div>"+data["workUnitText"]+"</div></td>";
        tr += "<td style='width:"+$(gridTheadTh[2]).width()+"px'><div>"+data["standardCapacity"]+"</div><input type='hidden' name='capacity["+capacityCount+"].standardCapacity' value='"+data["standardCapacity"]+"'/></td>";
        tr += "<td style='width:"+$(gridTheadTh[3]).width()+"px'><div>"+data["standardHours"]+"</div><input type='hidden' name='capacity["+capacityCount+"].standardHours' value='"+data["standardHours"]+"'/></td>";
        tr += "<td style='width:"+$(gridTheadTh[4]).width()+"px'><a title='<@label key='delete.B'>删除</@label>' target='ajax' class='btnDel' onclick='_delProcessCapacity(\""+data.workUnitCode+"\");'><@label key='delete.B'>删除</@label></a></td>";
        tr += "</tr>";
        $("tr#"+data.workUnitCode,  $currentDialog).remove();
        $("#processCapacityTable .gridTbody",  $currentDialog).find("table tbody").append(tr);
        capacityCount ++;
    }

    function _delProcessAttachment(_id) {
        if(_id && _id!="")
            $("tr#"+_id, $currentDialog).remove();
    }

    function _delProcessComponent(code) {
        if(code){
            $("tr#"+code, $currentDialog).remove();
        }
    }

    function _delProcessCapacity(code) {
        if(code){
            $("tr#"+code, $currentDialog).remove();
        }
    }

    function saveProcessOperation(form) {
        var $form = $(form);

        if (!$form.valid()) {
            return false;
        }
        $('#import_fileupload', $.pdialog.getCurrent()).uploadify('upload', '*');

    }
</script>
<script type="text/javascript" src="${rc.getContextPath()}/manage/js/businessJs/my_webuploader.js"></script>
<form method="post" action="${rc.getContextPath()}/manage/process/saveProcessOperation" class="pageForm required-validate" onsubmit="return validateCallback(this, popDialogAjaxDone)">
    <div class="pageContent">
    <div class="pageFormContent customFildset">
        <fieldset>
        <dl>
            <dt><@label key="operation.C,serialNumber.C,colon">工序序号：</@label></dt>
            <dd><input type="text" name="operationOrdinal" maxlength="20" class="required digits" /></dl>
        <dl class="notnormal">
            <dt><@label key="operation.C,colon">工序：</@label></dt>
            <dd>
                <input id="operationOrdinalLookup.operationText" readonly="readonly" type="hidden" name="operationText" type="text" />
                <input class="required look" id="operationOrdinalLookup.operationCode" name="operationCode" type="text" postField="operationCode" labelFields="operationCode,operationText" 
                suggestFields="operationCode,operationText,operationTypeEcode,operationTypeText,standardCapacity,standardHours" suggestUrl="${rc.getContextPath()}/manage/operation/operationSuggest" lookupGroup="operationOrdinalLookup" callback="_updaeTabsConetent"
                 warn="<@label key='operation.C,doesNotExist.C'>工序不存在</@label>"  remote="${rc.getContextPath()}/manage/operation/validateOperationLookUp"/>
                <a class="btnLook" href="${rc.getContextPath()}/manage/operation/operationLookUp?lookupType=radio" rel="operationLookUp_dialog" callback="_updaeTabsConetent" title="<@label key='select.C,operation.C'>选择工序</@label>" lookupGroup="operationOrdinalLookup" ></a>
            </dd>
        </dl>
        <dl>
        	<dt><@label key="standardCapacity.C,colon">标准产能</@label></dt>
        	<dd>
            	<input  name="standardCapacity" id="operationOrdinalLookup.standardCapacity" size="22" type="text" class="number" min="1" maxlength="9" />
        	</dd>
        </dl>
        <dl class="notnormal">
            <dt><@label key="standardHours.C,colon">标准用时</@label></dt>
            <dd>
                <input name="standardHours" id="operationOrdinalLookup.standardHours" size="22" type="text" class="number" min="1" maxlength="9" />
            </dd>
        </dl>
        <dl>
            <dt><@label key="operationType.C,colon">工序类型：</@label></dt>
            <dd><input type="text" id="operationOrdinalLookup.operationTypeText" maxlength="20" readonly="readonly"/></dd></dl>
        <dl class="notnormal">
            <dt><@label key="workUnitType.C,colon">作业单元类型：</@label></dt>
            <dd>
            <input id="workUnitTypeLookup.workUnitTypeCode" name="workUnitTypeCode" value="" type="hidden"/>
            <input class="look" id="workUnitTypeLookup.typeText" name="typeText" type="text" postField="workUnitTypeCode" suggestFields="workUnitTypeCode,typeText" 
                suggestUrl="${rc.getContextPath()}/manage/workUnit/workUnitTypeSuggest" lookupGroup="workUnitTypeLookup"/>
            <a class="btnLook" href="${rc.getContextPath()}/manage/workUnit/selectWorkUnitType?lookupType=radio" rel="workUnitType_dialog" title="<@label key='select.C,workUnitType.C'>选择作业单元类型</@label>" lookupGroup="workUnitTypeLookup" ></a>
            </dd>
        </dl>
        <dl>
            <dt><@label key="confirmPoint.C,colon">确认点：</@label></dt>
            <dd><input type="checkbox" name="confirmFlag" value="1" <#if confirmIsselected==true>checked</#if> /></dd>
        </dl>
        <dl  class="nowrap">
            <dt><@label key='description.C,colon'>备注：</@label></dt>
            <dd><textarea name="memo" rows="3" cols="40"></textarea></dd>
        </dl>    
        </fieldset>
    </div>
    <div class="tabs">
        <div class="tabsHeader">
            <div class="tabsHeaderContent">
                <ul>
                    <li id="component" data-selectedid="processOperation_component" class="exerInputS"><a href="javascript:;" id="select1"><span><@label key='attachment.C'>工艺附件</@label></span></a></li>
                    <li id="Capacity" data-selectedid="processOperation_Capacity" class="exerInputS"><a href="javascript:;" id="select4"><span><@label key='cmprocessCapacity.C'>工艺产能</@label></span></a></li>
                	<li id="attachment" data-selectedid="processOperation_attachment" class="exerInputS"><a href="javascript:;" id="select2"><span><@label key='component.C'>组件</@label></span></a></li>
                    <li id="quality" data-selectedid="processOperation_quality" class="exerInputS"><a href="javascript:;" id="select3"><span><@label key='qualityOperation.C'>质量工序设置</@label></span></a></li>
                    
                </ul>
            </div>
        </div>
        <div class="tabsContent" style="border-bottom: 1px #d8dfe5 solid;height:280px">
            <div>
                <div class="pageHeader">
                    <div id="uploader" class="wu-example">
                        <!--用来存放文件信息-->
                        <div id="processlist" class="uploader-list"></div>
                    </div>
                    <div id="processFile" class="choose-file" uploaderOption="{
                                    server:'${rc.getContextPath()}/manage/process/saveProcessAttachment',
                                    fileVal:'processfile',
                                    fileBnt: 'processFileBnt',
                                    fileList: 'processlist',
                                    beforeFileQueuedMsg: '<@label key='exeBat_type_msg.D'>请不要上传exe，bat，sh等可执行的文件</@label>',
                                    uploadSuccess: _addProcessAttachment
                                }"><@label key='chooseFile.C'>选择文件</@label></div>
                    <div class="buttonActive" style="float: right;">
                        <div class="buttonContent"><button id="processFileBnt" type="button"><@label key='upload.B'>上传</@label></button></div>
                    </div>
                </div>
                <table class="table canopration border" style="width: 100%;" id="processAttachMentTable">
                    <thead>
                        <tr>
                            <th width="100px"><@label key='fileName.C'>文件名称</@label></th>
                            <th width="100px"><@label key='fileSize.C'>文件大小(bytes)</@label></th>
                            <th width="100px"><@label key='version.C'>版本</@label></th>
                            <th width="50px"><@label key="opera.C">操作</@label></th>
                        </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>
            <div>
                <div class="panelBar">
                    <ul class="toolBar">
                        <li><a class="add " target="dialog" mask="true" width="450" height="280" rel="addProcessCapacity" title="<@label key='addWorkUnit.D'>新增作业单元</@label>"
                        href="${rc.getContextPath()}/manage/process/addProcessCapacity"><span><@label key="add.B">新增</@label></span></a></li>
                    </ul>
                </div>
                <table id="processCapacityTable" class="table canopration" style="width: 100%;" layoutH="340">
                    <thead>
                        <tr>
                            <th width="70px"><@label key="workUnitCode.C">作业单元编号</@label></th>
                            <th width="70px"><@label key="workUnitText.C">作业单元名称</@label></th>
                            <th width="50px"><@label key="standardCapacity.C">标准产能</@label></th>
                             <th width="50px"><@label key="standardHours.C">标准用时</@label></th>
                            <th width="50px"><@label key="opera.C">操作</@label></th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
            <div>
                <div class="panelBar">
                    <ul class="toolBar">
                        <li><a class="add " target="dialog" mask="true" width="450" height="280" rel="addProcessComponent" title="<@label key='add.B,component.C'>新增组件</@label>"
                        href="${rc.getContextPath()}/manage/process/addProcessComponent"><span><@label key="add.B">新增</@label></span></a></li>
                    </ul>
                </div>
                <table id="processComponentTable" class="table canopration" style="width: 100%;" layoutH="340">
                    <thead>
                        <tr>
                            <th width="50px"><@label key="component.C,code.C">组件编号</@label></th>
                            <th width="100px"><@label key="component.C,name.C">组件名称</@label></th>
                            <th width="30px"><@label key="quantity.C">数量</@label></th>
                            <th width="50px"><@label key="opera.C">操作</@label></th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
            <div>
                <div class="pageHeader">
                    <fieldset class="pageFormContent">
                        <dl>
                            <dt>选择采集方式</dt>
                            <dd>
                                <input type="checkbox" name="textcollectFlag" value="1"/>文本
                                <input type="checkbox" name="graphcollectFlag" value="1"/>图形
                            </dd>
                        </dl>
                        <dl>
                            <dt>默认采集类型</dt>
                            <dd>
                                <select name="collectModeEcode" >
                                    <#if defectcollectMode??>
                                        <#list defectcollectMode as ecode>
                                            <option value="${ecode.eCode!''}">${ecode.eCodeText!''}</option>
                                        </#list>
                                    </#if>
                                </select>
                            </dd>
                        </dl>
                    </fieldset>
                    <div id="uploadProcessInspectPicture">
                        <div id="uploader" class="wu-example">
                            <!--用来存放文件信息-->
                            <div id="processPictureList" class="uploader-list"></div>
                        </div>
                        <div id="processPictureFile" class="choose-file" uploaderOption="{
                                    server:'${rc.getContextPath()}/manage/process/saveProcessinspectpicture',
                                    fileVal:'processPicture',
                                    fileBnt: 'processPictureBnt',
                                    fileList: 'processPictureList',
                                    beforeFileQueuedMsg: '<@label key='exeBat_type_msg.D'>请不要上传exe，bat，sh等可执行的文件</@label>',
                                    uploadSuccess: _addInspectPicture
                                }"><@label key='chooseFile.C'>选择文件</@label></div>
                        <div class="buttonActive" style="float: right;">
                            <div class="buttonContent"><button id="processPictureBnt" type="button"><@label key='upload.B'>上传</@label></button></div>
                        </div>
                    </div>
                </div>
                <table class="table canopration" style="width: 100%;" id="processInspectPicTable">
                    <thead>
                        <tr>
                            <th width="100px"><@label key='fileName.C'>文件名称</@label></th>
                            <th width="100px"><@label key='fileSize.C'>文件大小(bytes)</@label></th>
                            <th width="50px"><@label key="opera.C">操作</@label></th>
                        </tr>
                    </thead>
                    <tbody>
                        
                    </tbody>
                </table>
            </div>
            
        </div>
    </div>
    <div class="formBar">
        <ul>
            <li><div class="buttonActive"><div class="buttonContent"><button type="submit"><@label key="save.B">保存</@label></button></div></div></li>
            <li>
                <div class="buttonActiveGrey"><div class="buttonContent"><button type="button" class="close"><@label key="cancel.B">取消</@label></button></div></div>
            </li>
        </ul>
    </div>
    </div>
</form>

